#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int flag[10];
	int n;
	scanf("%d",&n);
	for(int i = n+1;i<=9876;i++)
	{
		int sign = 0;
		memset(flag,0,sizeof(flag));
		int t = i;
		while(t)
		{
			int x = t%10;
			t = t/10;
			if(!flag[x]) flag[x] = 1;
			else 
			{
				sign = 1;
				break;
			}
		}
		if(!sign)
		{
			printf("%d\n",i);
			return 0;
		} 
	}
} 
